<?php
/*********************************************************************\
* This File is a part of BH-PANEL (Breizh-Heberg Panel v2.1)
* Copyright (C) 2008-2009 the BH Developpers : Vincent Giersch <mail@vincordi.fr>, Cyprien Laleau <fanning.fr@gmail.com> and Edwin Cabiten <marmottes44@hotmail.fr>
* See file AUTHORS to get more informations

* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.

* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.

* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
/*********************************************************************/

if(isset($_SESSION['u_nic'])) {
	include('php/lib/panel_inc.php');
		$infos_users = mysql_fetch_array(query("SELECT u_affiliation FROM users WHERE u_nic = '".$_SESSION['u_nic']."'"));
		if(($infos_users['u_affiliation'] == 1) AND ($bzh_config['affiliation_pc'] != 0)) {
			$tpl->assign(array(
				'iconesleft' => 1,
				'affiliation_pc' => $bzh_config['affiliation_pc'],
				'u_nic' => $_SESSION['u_nic']
				
			));
			if($_GET['action'] == "visuels") {
				$title = "Affiliation Breizh Héberg";
				$tplinc = "panel-general-affiliation-visuels";
				$parse = 1;
			
			}
			elseif($_GET['action'] == "history") {
				$_history = query("SELECT 
										affiliations_users.*,
										offres.id AS o_id,
										offres.nom
										FROM affiliations_users 
										LEFT JOIN offres
										ON affiliations_users.offre = offres.id
										WHERE p_u_nic = '".$_SESSION['u_nic']."' AND etat = 1 ORDER by id DESC");
				While($history = mysql_fetch_array($_history)) {
					$tpl->assign_array('ahi',$history);
				}
				$title = "Historique de l'affiliation Breizh Héberg";
				$tplinc = "panel-general-affiliation-history";
				$parse = 1;
			}
			else {
				$title = "Affiliation Breizh Héberg";
				$tplinc = "panel-general-affiliation";
				$parse = 1;
			}
		}
		else { header("Location: /panel/index.html"); }
}
else { header("Location:/site/connexion.html"); }
?>